const http = require("http");
const fs = require("fs");

http
  .createServer(function (request, response) {
    console.log("request come", request.url);
    const html = fs.readFileSync("test.html", "utf8");
    response.writeHead(200, {
      "Content-Type": "text/html",
      //"Content-Type": "text/plain", // 这样写会把数据按照html源码的格式展示，而不是解析成页面
    });
    response.end(html);
  })
  .listen(8888);

console.log("server listening on 8888");
